package com.tte.common.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tte.common.mapper.DictionaryMapper;
import com.tte.common.model.po.Dictionary;
import com.tte.common.service.DictionaryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典实现类
 * @Author: DongWH
 * @Date: 2022/6/21 15:40
 */
@Service
public class DictionaryServiceImpl implements DictionaryService {
    @Resource
    private DictionaryMapper dictionaryMapper;

    /**
     * @Param pageNum 页码
     * @Param pageSize 页面大小
     * @return: 分页对象
     */
    @Override
    public PageInfo selectAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<Dictionary> pageInfo = new PageInfo<>(dictionaryMapper.selectAll());
        return pageInfo;
    }


    /**
     * @Param pageNum 页码
     * @Param pageSize 页面大小
     * @Param order 排序字段
     * @return: 分页对象
     */
    @Override
    public PageInfo selectAll(int pageNum, int pageSize, String order) {
        PageHelper.startPage(pageNum,pageSize,order);
        List<Dictionary> list = dictionaryMapper.selectAll();
        PageInfo<Dictionary> pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public List<Dictionary> getByTypes(List<String> cTypes) {
        return dictionaryMapper.getByTypes(cTypes);
    }
}
